import { reqCategory, reqBannerList, reqFloorList } from "@/api";
//home 模型的小仓库
const state = {
    // home仓库中存储三级菜单的数据
    categoryList: [],
    // 轮播图的数据
    bannerList: [],
    floorList: [],
};
// mutations是唯一修改state的地方
const mutations = {
    CATEGORYLIST(state, categoryList) {
        state.categoryList = categoryList;
    },
    GETBANNERLIST(state, getBannerList) {
        state.bannerList = getBannerList;
    },
    GETFLOORLIST(state, getFloorList) {
        state.floorList = getFloorList
    }
};
// action|用户处理派生action的地方，可以书写异步语句、自己逻辑的地方
const actions = {
    async categoryList({ commit }) {
        let result = await reqCategory();
        console.log(result);
        if (result.code == 200) {
            commit('CATEGORYLIST', result.data);
        }
    },
    //(模拟) Banner轮播图数据
    async getBannerList({ commit }) {
        let result = await reqBannerList();
        console.log(result)
        if (result.code == 200) {
            commit("GETBANNERLIST", result.data);
        }
    },
    async getFloorList({ commit }) {
        let result = await reqFloorList();
        if (result.code == 200) {
            commit("GETFLOORLIST", result.data)
        }
    },
};
// 计算属性
const getters = {};

export default {
    state,
    mutations,
    actions,
    getters
}